package com.ethink.platform.controller.warehouse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import com.ethink.framework.common.web.BaseController;
import com.ethink.framework.common.web.response.CommonResponse;
import com.ethink.warehouse.api.MateProduceCodeFacade;
import com.ethink.warehouse.api.info.MateProduceCodeInfo;
import com.ethink.warehouse.api.request.MateProduceCodeAddRequest;
import com.ethink.warehouse.api.request.MateProduceCodeQueryRequest;
import com.ethink.warehouse.api.request.MateProduceCodeUpdateRequest;

/**
 * 商品生产批次号 Controller
 *
 * @author default
 * @date 2022-11-22
 */
@Tag(name = "MateProduceCodeController", description = "商品生产批次号 Controller")
@RestController
@Slf4j
@RequestMapping("platform-server/v1/warehouse-service")
public class MateProduceCodeController extends BaseController {

    @Autowired
    private MateProduceCodeFacade mateProduceCodeFacade;

    @Operation(summary = "分页查询")
    @GetMapping("/mateProduceCode/query")
    public CommonResponse<List<MateProduceCodeInfo>> queryMateProduceCode(MateProduceCodeQueryRequest request) {
        return succeedWithPage(mateProduceCodeFacade.queryMateProduceCode(request));
    }

    @Operation(summary = "详情查询")
    @GetMapping("/mateProduceCode/get/{mateProduceCodeId}")
    public CommonResponse<MateProduceCodeInfo> getMateProduceCodeById(@PathVariable("mateProduceCodeId") Long mateProduceCodeId) {
        return succeedWith(mateProduceCodeFacade.getMateProduceCodeById(mateProduceCodeId));
    }

    @Operation(summary = "查询所有")
    @GetMapping("/mateProduceCode/list")
    public CommonResponse<List<MateProduceCodeInfo>> listMateProduceCode(MateProduceCodeQueryRequest request) {
        return succeedWith(mateProduceCodeFacade.listMateProduceCode(request));
    }

    @Operation(summary = "新增")
    @PostMapping("/mateProduceCode/add")
    public CommonResponse addMateProduceCode(@RequestBody MateProduceCodeAddRequest request) {
        mateProduceCodeFacade.addMateProduceCode(request);
        return succeed();
    }

    @Operation(summary = "更新")
    @PutMapping("/mateProduceCode/update")
    public CommonResponse updateMateProduceCode(@RequestBody MateProduceCodeUpdateRequest request) {
        mateProduceCodeFacade.updateMateProduceCode(request);
        return succeed();
    }

    @Operation(summary = "删除")
    @PutMapping("/mateProduceCode/delete/{mateProduceCodeId}")
    public CommonResponse deleteMateProduceCode(@PathVariable("mateProduceCodeId") Long mateProduceCodeId) {
        mateProduceCodeFacade.deleteMateProduceCode(mateProduceCodeId);
        return succeed();
    }

}